﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using Microsoft.Practices.Unity.InterceptionExtension;

namespace Thallo {
    static class Helper {
        public static string GetExcutePath( ) {
            return AppDomain.CurrentDomain.RelativeSearchPath ?? AppDomain.CurrentDomain.BaseDirectory;
        }


        public static RuntimeMethodHandle FindMethodHandle(string assemblyName,string typeName, string methodName) {
            throw new NotImplementedException();
        }

        public static IEnumerable<object> GetValues(this IParameterCollection parameters) {
            for (int i = 0; i < parameters.Count; i++) {
                yield return parameters[i];
            }
        }

        public static string GetKey(System.Reflection.MethodBase mi, IEnumerable inputs) {
            List<string> lst = new List<string>();
            var prefix = mi.MethodHandle.Value.ToString();
            lst.Add(prefix);
            var index = 0;
            foreach (var item in inputs) {
                var parser = ParameterParserFactory.GetParser(mi, index);
                lst.Add( parser.ParseKey(item));
            }
            var ps = string.Join(",", lst).GetHashCode();
            return "st_" + ps.ToString();
        }
    }
}
